getMemoryLimit(); if ($memoryLimit === null) { return; } $this->validateMemoryLimitFormat($memoryLimit); $memorySetResult = \ini_set('memory_limit', $memoryLimit); if ($memorySetResult === \false) { $errorMessage = \sprintf('Memory limit "%s" cannot be set.', $memoryLimit); throw new InvalidConfigurationException($errorMessage); } } private function validateMemoryLimitFormat(string $memoryLimit) : void { $memoryLimitFormatMatch = Strings::match($memoryLimit, self::VALID_MEMORY_LIMIT_REGEX); if ($memoryLimitFormatMatch !== null) { return; } $errorMessage = \sprintf('Invalid memory limit format "%s".', $memoryLimit); throw new InvalidConfigurationException($errorMessage); } }